#a guessing game where a number 1 through 100 is generated and the user gets 3 tries to guess
#Fine imports
import random
#makin functions:1. check if number is or not the random number
#tell if user won or lost
#hit maxtries or not
#
#
#
#
class Message:
        block = """
______                _                   _   _                 _               
| ___ \              | |                 | \ | |               | |              
| |_/ /__ _ _ __   __| | ___  _ __ ___   |  \| |_   _ _ __ ___ | |__   ___ _ __ 
|    // _` | '_ \ / _` |/ _ \| '_ ` _ \  | . ` | | | | '_ ` _ \| '_ \ / _ \ '__|
| |\ \ (_| | | | | (_| | (_) | | | | | | | |\  | |_| | | | | | | |_) |  __/ |   
\_| \_\__,_|_| |_|\__,_|\___/|_| |_| |_| \_| \_/\__,_|_| |_| |_|_.__/ \___|_|   

        
 _____                                                                          
|  __ \                                                                         
| |  \/ __ _ _ __ ___   ___                                                     
| | __ / _` | '_ ` _ \ / _ \                                                    
| |_\ \ (_| | | | | | |  __/                                                    
 \____/\__,_|_| |_| |_|\___|   """              
        intro = "WELCOME! I have right here a number from 1 to 100. You have three tries to guess it!"
        FirstGuess = "Tell me what you think the number is?"
        retry = 'Hmm... \n*checks notes* \nThat number is wrong. \nTry again!', 'You go \nSorry, I read that wrong. \nYou didn\'t get it right. \nTry again.', 'Aww. Wrong number.\nTry again!'
        lasttry = 'One more time!\nYou can do it!', 'IT IS THE FINAL ROUND OF THE MATCH!\nFIGHT!', 'This is your last chance!\nWhat is your guess?'
        victorymsg = 'You did it!', 'Congratulations!', 'You won!', 'Victory!'
        gameover = 'You tried your best! \nBut.... this is a guessing game so you really couldn\'t do much', 'Sorry, all those guesses are wrong :(', 'All were wrong, try again later!'
        
        def open():
                print(intro)
        def win():
                
                print random.choice(victorymsg)
        def gover(a):
                a-0
                print random.choice(gameover)
class Menu:
        state = 0
        wins = 0
        intmenu = "Do you want to Play? (1/Play) Quit (Q/Quit) or view the High Score? (2/Score)"
        def display(a):
                #OH GOD THIS IS SUPER HACKY AND I HAVE NO IDEA WHAT ELSE TO DO maybe I should just learn 6502 asm
                a = 0
                
                print intmenu
                #print state
        def ginput(letter):
                
                #print intmenu
                state = 0
                letter = raw_input("Choice: ")
                command ={'1':1,'Play':1,'play':1,'quit':666,'Quit':666,'QUIT':666,'score':3,'Score':3,'Q':666,'2':3,'q':666,'8':8,'9':9}
                return command[letter]
                
                        
            
#will hold multiple values, may not use them all
#might just implement in menu system
class Scoring:
        #current/last game record
        guessed = 0
        wins = 0
        def viewscore():
                return
        def addscore():
                wins += 1
                return wins
        def addguess():
                guessed += 1
                return guessed
        
        ##### do I even put everything of the game loop in an object???####
class Guessing:
        #maxtries = 3
        #tries = 0
        
        randy = random.randint(1,100)
        # it will need to get an answer from the player
        # check the number against the random number
        # check number of tries
        

        

        def getanswer(answer):
                
                answer = input("My answer is: ")
                return answer
                #add tries to current Guessing object?
              
                

        def checktries(tries,maxtries):
               # maxtries = 3
                if tries == maxtries:
                        return False
                if tries < maxtries:
                        return True
                #checks the tries that exist
        def addtry(tries):
                tries += 1

        def checkcon():
                if answer == rando:
                        return False
                else:
                        return True
                #checks if you won yet or lost
                #returns true if continue
                #returns win/lose or some state thing?
        def checkwin():
                if answer == rando and tries <= maxtries:
                        return True
                else:
                        return False
def numchk(a, b):
        if a == b:
                return True
        else:
                return False

############################
#debug show number toggle
debug = 0
##########################################                
#######   new code !!!!!!!!!!!!!!!!!!!##############################
#state used to set if you won/lost?
state = 0
#tries = 0
intro = Message()
mmenu = Menu()
intmenu = mmenu.intmenu
wins = 0
print intro.block
print intro.intro
while 1:
        while state == 0:
        
                #mmenu = Menu()
                if debug == 1:
                        print state
                mmenu.display()
                state = mmenu.ginput()
                if debug == 1:
                        print state
                if state == 3:
                #highscore
                
                        print "Current wins: ", wins
                        state = 0
                if state == 9:
                        print "debug on"
                        debug = 1
                        state = 0
                if state == 8:
                        print "debug off"
                        debug = 0
                        state = 0
        
        if state == 1:
                #I have no idea what to do
                #TODO: move scores into object stuff
                #Figure out how to safely move game logic into more objects
                #
                rando = random.randint(1,100)
                tries = 0
                maxtries = 3
                print intro.FirstGuess
                newgame = Guessing()
                if debug == 1:
                        print rando
                answer = newgame.getanswer()
                tries += 1
                #print newgame.rando
                #newgame.getanswer()
                ##################### TEMP ############################
                while not numchk(answer,rando) and not numchk(tries,maxtries):
                        if tries == 1:
                                print random.choice(intro.retry)
                        if tries == 2:
                                print random.choice(intro.lasttry)
                        answer = newgame.getanswer()
	                tries += 1
                if numchk(answer,rando):
                        print random.choice(intro.victorymsg)
                        wins += 1
	                state = 0
                elif numchk(tries,maxtries):
        
	                print random.choice(intro.gameover)
                        print "the number was: ", rando
                        wins = 0
                        state = 0
                else:
                        print "this shouldn't happen"
        

        if state == 666:
                print("bye!")
                quit()






#print rando

#	print "!!!!!!!!!!!!!  \n\n\n\n !!!!!!!!!!!!!!!!!!!!!"

#Intro and request input number

#print intro
#print "Tell me a number between 1 and ", limit, "!"
#answer = getanswer()
#tries += 1
#while not numchk(answer,rando) and not numchk(tries,maxtries):
 #       answer = getanswer()
#	tries += 1
#if numchk(answer,rando):
 #       print random.choice(victorymsg)
	
#elif numchk(tries,maxtries):
        
#	print random.choice(gameover)
#	print rando
#else:
 #       print "this shouldn't happen"



#


